package org.cmroot.certmaster.model;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.Arrays;

/**
 * Copyright (c) 2010 Andrey Domas <andrey.domas at gmail.com>.
 * *
 * This file is part of certmaster.
 * *
 * Certmaster is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * *
 * Certmaster is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 */

@MappedSuperclass
public abstract class PKCS implements ForDTO{

    @Id
    @GeneratedValue
    @Column
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    protected Long id;

    @Column(nullable = false)
    public String getCN() { return cn; }
    public void setCN(String cn) { this.cn = cn; }
    protected String cn;

    @Column(nullable = false)
    public int getVersion() { return version; }
    public void setVersion(int version) { this.version = version; }
    private int version;

    @Column(nullable = false)
    public byte[] getDer() { return der; }
    public void setDer(byte[] der) { this.der = der; }
    protected byte[] der;

    public boolean equals(PKCS o) {
        return Arrays.equals(this.der, o.getDer());
    }

}
